import tensorflow as tf
from tensorflow import keras
import Mynet_tensorflow
import numpy as np

batch_size=32
data = Mynet_tensorflow.Load_data()
load_model = keras.models.load_model('trained_model')
Sparse_categorical_accuracy = keras.metrics.SparseCategoricalAccuracy()
test_cycle_times = int(data.test_num//batch_size)
for i in range(test_cycle_times):
    start_index, end_index = i*batch_size, (i+1)*batch_size
    test_y_pred = load_model(data.test_x[start_index:end_index])
    Sparse_categorical_accuracy.update_state(y_true=data.test_y[start_index:end_index],y_pred=test_y_pred)
print('准确度：',Sparse_categorical_accuracy.result())
